<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="demo">
        <input v-model="text" placeholder="输入连接或者文字等生成二维码" />
        <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
    </div>
    <script src="js/qrcode.js"></script>
    <script src="js/vue2.js"></script>
    <script>
        new Vue({
            el: "#demo",
            data: {
                text:"wscats",
                qrcode: null
            },
            mounted: function () {
                this.qrcode = new QRCode(document.getElementById("qrcode"), {
                    width: 100,
                    height: 100
                })
                this.qrcode.makeCode(this.text);
            },
            watch:{
                text:function(){
                    // 触发生成qrcode二维码
                    this.qrcode.makeCode(this.text);
                    return this.text
                }
            }
        })
    </script>
</body>
</html>
